<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>更新用户信息</title>
    <link rel="stylesheet" th:href="@{/bootstrap/css/bootstrap.css}">
    <link rel="stylesheet" th:href="@{/css/common.css}">
</head>
<body>
<div th:insert="~{common/header::header1}"></div>
<div class="container-fluid">
    <div class="row">
        <div class="col-md-offset-3 col-md-6">
            <form id="form1" th:action="@{/user-info/update.do}">
                <div>
                    <input type="hidden" id="id" name="userId" th:value="${user.getUserId()}">
                </div>
                <div class="form-group row justify-content-sm-center">
                    <label for="loginName" class="col-sm-2 col-form-label font-weight-bold">登录名</label>
                    <div class="col-sm-5">
                        <div th:if="${session.loginUser.getRole() eq 1}">
                            <input type="text"  class="form-control " id="loginName" th:value="${user.getLoginName()}" name="loginName">
                        </div>
                        <div th:if="${session.loginUser.getRole() eq 0}">
                            <input type="text"  class="form-control " readonly id="loginName" th:value="${user.getLoginName()}" name="loginName">
                        </div>
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center">
                    <label for="name" class="col-sm-2 col-form-label font-weight-bold">姓名</label>
                    <div class="col-sm-5">
                        <input th:if="${session.loginUser.getRole() eq 1}" type="text"  class="form-control " id="name" th:value="${user.getUserName()}" name="userName">
                        <input th:if="${session.loginUser.getRole() eq 0}" type="text"  class="form-control " readonly id="name" th:value="${user.getUserName()}" name="userName">
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center">
                    <label for="name" class="col-sm-2 col-form-label font-weight-bold">性别</label>
                    <div class="col-sm-5">
                        <input  type="radio" name="sex" th:value="1" th:checked="${session.loginUser.getSex() eq 1}">男
                        <input type="radio" name="sex" th:value="0" th:checked="${session.loginUser.getSex() eq 0}">女
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center">
                    <label for="inputPassword" class="col-sm-2 col-form-label font-weight-bold">密码</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control " id="inputPassword" th:value="${user.getPassword()}" name="password">
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center">
                    <label for="phone" class="col-sm-2 col-form-label font-weight-bold">手机号码</label>
                    <div class="col-sm-5">
                        <input type="text" class="form-control " id="phone" th:value="${user.getPhone()}" name="phone">
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center">
                    <label for="email" class="col-sm-2 col-form-label font-weight-bold">邮箱</label>
                    <div class="col-sm-5">
                        <input type="text"  class="form-control " id="email" th:value="${user.getEmail()}" name="email">
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center" th:if="${session.loginUser.getRole() eq 1}">
                    <label for="disabled" class="col-sm-2 col-form-label font-weight-bold">是否激活</label>
                    <div class="col-sm-5">
                        <select class="form-control" name="disabled" id="disabled">
                            <option th:value="1" th:checked="${session.loginUser.getDisabled() eq 1}">是</option>
                            <option th:value="0" th:checked="${session.loginUser.getDisabled() eq 0}">否</option>
                        </select>
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center" th:if="${session.loginUser.getRole() eq 1}">
                    <label for="role" class="col-sm-2 col-form-label font-weight-bold">权限</label>
                    <div class="col-sm-5">
                        <select class="form-control" name="role" id="role">
                            <option th:value="0" th:checked="${session.loginUser.getRole() eq 0}">普通用户</option>
                            <option th:value="1" th:checked="${session.loginUser.getRole() eq 1}">管理员</option>
                        </select>
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center" th:if="${session.loginUser.getRole() eq 0}">
                    <div>
                        <input type="hidden" th:value="0" name="role">
                    </div>
                </div>
                <div class="form-group row justify-content-sm-center">
                    <div class="col-sm-1">
                        <button class="btn btn-sm btn-success" type="submit">提交</button>
                    </div>
                    <div class="col-sm-1"></div>
                    <div class="col-sm-1">
                        <button  class="btn btn-sm btn-primary" th:if="${session.loginUser.getRole() eq 0}"><a style="color: white" th:href="@{/}" >取消</a></button>
                        <button  class="btn btn-sm btn-primary"th:if="${session.loginUser.getRole() eq 1}"><a style="color: white" th:href="@{/user-info/show.do}" >取消</a></button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

</body>
</html>